<html>
<head><meta charset="utf-8"><title>const args in type dependent paths · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html">const args in type dependent paths</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194857984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194857984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194857984">(Apr 21 2020 at 20:35)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71154" title="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a></p>



<a name="194858109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194858109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194858109">(Apr 21 2020 at 20:36)</a>:</h4>
<p>Both incremental tests and cross crate builds don't fully work yet.</p>



<a name="194859482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194859482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194859482">(Apr 21 2020 at 20:49)</a>:</h4>
<p>When calling <code>typeck_tables_of(const_arg)</code> where <code>const_arg</code> is from an external crate, we must have already computed and stored this.<br>
As my PR calls <code>typeck_tables_of_const_arg(const_arg, param_def_id)</code> instead, this is not always the case.</p>
<p>I circumvent this inside the local crate, as I call <code>const_param_of</code> at the start of <code>typeck_tables_of</code>. <a href="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/check/mod.rs#L981-L986" title="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/check/mod.rs#L981-L986">https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/check/mod.rs#L981-L986</a><br>
<code>const_param_of</code> also requires the HIR though, meaning that this approach doesn't work for external <code>DefId</code>s.</p>
<p>I think that the easiest way to solve this is by storing <code>const_param_of</code> on disk for all const arguments and add a wrapper for <code>typeck_tables_of(def_id)</code> which calls <code>const_param_of</code> for all const arguments "inside" of <code>def_id</code>after executing the query.<br>
<code>const_param_of</code> can now safely call <code>typeck_tables_of(body_owner)</code> without cycles, as we just computed this.</p>
<p>We can now safely return <code>None</code> in <code>const_param_of</code> if <code>tcx.hir().as_local_hir_id(def_id)</code> fails. <a href="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24" title="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24">https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24</a></p>
<p>Does this sound like a fairly clean approach? <span class="user-mention" data-user-id="121053">@varkor</span></p>



<a name="194957278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194957278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194957278">(Apr 22 2020 at 16:32)</a>:</h4>
<p>Why is <code>ensure</code> used in <code>typeck_item_bodies</code>? <a href="https://github.com/rust-lang/rust/blob/00f677d8974b393ff32ca25bf916b6b9650c75b0/src/librustc_typeck/check/mod.rs#L751-L754" title="https://github.com/rust-lang/rust/blob/00f677d8974b393ff32ca25bf916b6b9650c75b0/src/librustc_typeck/check/mod.rs#L751-L754">https://github.com/rust-lang/rust/blob/00f677d8974b393ff32ca25bf916b6b9650c75b0/src/librustc_typeck/check/mod.rs#L751-L754</a></p>



<a name="194967514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194967514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194967514">(Apr 22 2020 at 17:49)</a>:</h4>
<p>Are all const arguments body owners?</p>



<a name="194989275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194989275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194989275">(Apr 22 2020 at 20:47)</a>:</h4>
<p>Incremental tests now pass on local, so I hope that most of my work is finally done here <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<p>Thiis PR introduces a <em>small</em> amount of complexity and requires a lot of effort by <span class="user-mention" data-user-id="119009">@eddyb</span> and <span class="user-mention" data-user-id="121053">@varkor</span> to review it.<br>
Are there some smallish + unrelated refactorings I can do in the near future?</p>
<p><span class="user-mention" data-user-id="120823">@DPC</span> if I remember correctly you had things you could use some help for</p>



<a name="194989331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194989331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DPC <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194989331">(Apr 22 2020 at 20:47)</a>:</h4>
<p>hi Bastian. Yeah i need to dig up some issues so i'll try today or tomorrow and ping you accordingly <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="194989876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194989876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194989876">(Apr 22 2020 at 20:52)</a>:</h4>
<p>Sorry, I saw the notification, and then forgot to respond.</p>



<a name="194989883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194989883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194989883">(Apr 22 2020 at 20:52)</a>:</h4>
<p>I'm not sure about <code>ensure</code>.</p>



<a name="194990088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194990088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194990088">(Apr 22 2020 at 20:54)</a>:</h4>
<p>I'll try to review the PR reasonably soon.</p>



<a name="194990110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/194990110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#194990110">(Apr 22 2020 at 20:54)</a>:</h4>
<p>But I have some deadlines this week, so I may not get to it right away.</p>



<a name="195046063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195046063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195046063">(Apr 23 2020 at 11:16)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71154" title="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a> now passes CI, can someone run perf for this?</p>



<a name="195061658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195061658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195061658">(Apr 23 2020 at 13:38)</a>:</h4>
<p>(deleted)</p>



<a name="195063314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195063314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DPC <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195063314">(Apr 23 2020 at 13:51)</a>:</h4>
<p>once github is working normally, sure :P</p>



<a name="195063577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195063577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DPC <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195063577">(Apr 23 2020 at 13:53)</a>:</h4>
<p>rdone</p>



<a name="195223830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195223830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195223830">(Apr 24 2020 at 17:58)</a>:</h4>
<p>I changed <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/sealed/trait.IntoQueryParam.html" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/sealed/trait.IntoQueryParam.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/query/sealed/trait.IntoQueryParam.html</a> to <code>pub(crate)</code> as I need to wrap some often used queries and want the wrapper to also accept both <code>DefId</code> and<code>LocalDefId</code></p>



<a name="195230286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195230286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195230286">(Apr 24 2020 at 18:56)</a>:</h4>
<p><span class="user-mention" data-user-id="120823">@DPC</span> can you retry the perf run <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> the last one failed for a reason I don't quite understand</p>



<a name="195231374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195231374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> DPC <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195231374">(Apr 24 2020 at 19:06)</a>:</h4>
<p>sure</p>



<a name="195272962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195272962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195272962">(Apr 25 2020 at 07:39)</a>:</h4>
<p>I thought that a rebase after <code>@bors try</code> does not stop perf <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="195273033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195273033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195273033">(Apr 25 2020 at 07:41)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> I just realised how to simplify the PR <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> The longer it takes until you to have enough time, the easier it will be in the end.<br>
Will take a few days to implement <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="195301804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195301804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195301804">(Apr 25 2020 at 20:35)</a>:</h4>
<p>Seems like it only took 1 day <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> <a href="https://github.com/rust-lang/rust/pull/71154#issuecomment-619437246" title="https://github.com/rust-lang/rust/pull/71154#issuecomment-619437246">https://github.com/rust-lang/rust/pull/71154#issuecomment-619437246</a></p>



<a name="195377879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195377879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195377879">(Apr 27 2020 at 06:41)</a>:</h4>
<p>I still won't get to it for a while, but maybe next weekend</p>



<a name="195378087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195378087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195378087">(Apr 27 2020 at 06:45)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> That's far sooner than I expected <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> So don't worry</p>



<a name="195393360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195393360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195393360">(Apr 27 2020 at 09:36)</a>:</h4>
<p><span class="user-mention" data-user-id="120823">@DPC</span>  can you retry the perf run <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> the last one didn't run for a reason I don't quite understand</p>



<a name="195393389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195393389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195393389">(Apr 27 2020 at 09:37)</a>:</h4>
<p>I won't touch this in the next few days, so we should be safe this time <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="195686651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/195686651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#195686651">(Apr 29 2020 at 10:07)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>please look at <a href="https://github.com/rust-lang/rust/pull/71477" title="https://github.com/rust-lang/rust/pull/71477">https://github.com/rust-lang/rust/pull/71477</a> beforehand. It's a tiny fix needed for  <a href="https://github.com/rust-lang/rust/pull/71154" title="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a></p>



<a name="196096512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196096512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196096512">(May 03 2020 at 10:41)</a>:</h4>
<p>Once again thought of an improvement <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> pls no review rn</p>



<a name="196102966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196102966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196102966">(May 03 2020 at 13:14)</a>:</h4>
<p>seems like this refactoring ended up being a dead end <span aria-label="disappointed" class="emoji emoji-1f61e" role="img" title="disappointed">:disappointed:</span> <code>124 files changed, 750 insertions(+), 800 deletions(-)</code></p>



<a name="196123354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123354">(May 03 2020 at 21:07)</a>:</h4>
<p>I am somewhat finished but am still not completely satisfied <span aria-label="oh no" class="emoji emoji-1f615" role="img" title="oh no">:oh_no:</span> There are &gt;40 calls to <code>typeck_tables_of</code> which I did not yet reach during typeck. As all I don't want to recompute <code>typeck_tables_of</code> twice for const arguments I added a thin wrapper which gets the correct <code>DefId</code> of the generic parameter and then calls the actual query(which is now renamed to <code>_typeck_tables_of</code>).</p>



<a name="196123438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123438">(May 03 2020 at 21:08)</a>:</h4>
<p>I would have to add the same wrapper to <code>TyCtxtEnsure</code> as there are multiple <code>tcx.ensure().typeck_tables_of</code> calls which I currently had to manually edit to <code>tcx.ensure()._typeck_tables_of</code> which is not great</p>



<a name="196123467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123467">(May 03 2020 at 21:09)</a>:</h4>
<p>I can currently think of 3 ways I could go:</p>



<a name="196123585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123585">(May 03 2020 at 21:11)</a>:</h4>
<p>remove the wrapper for <code>typeck_tables_of</code> and get the correct generic param at the start of this query and then call the same query with the correct arguments. This still requires me to modify all 40+ callsites of this function and causes cycle errors to be longer.</p>



<a name="196123719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123719">(May 03 2020 at 21:14)</a>:</h4>
<p>Change all occurences of <code>typeck_tables_of(input)</code> to <code>typeck_tables_of(tcx.with_opt_param(input))</code>. While this changes even more locations,<br>
it doe s not require any wrappers and is probably the cleanest solution.</p>



<a name="196123819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123819">(May 03 2020 at 21:16)</a>:</h4>
<p>Also add a wrapper to <code>TyCtxtEnsure</code> for <code>typeck_tables_of</code>, this duplicates the wrapper and would be the first ever methods added to this struct, so I don't feel comfortable doing this. Also leaves us with <code>_query_name</code>, which I kind of dislike.</p>



<a name="196123846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196123846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196123846">(May 03 2020 at 21:17)</a>:</h4>
<p>I am personally in favor of option 2 but dislike all of them <span aria-label="distraught" class="emoji emoji-1f629" role="img" title="distraught">:distraught:</span></p>



<a name="196159258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/196159258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#196159258">(May 04 2020 at 09:38)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> The refactoring has been finished. Reduced the size to <code>101 files changed, 1069 insertions(+), 467 deletions(-)</code> <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="198603390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/198603390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#198603390">(May 24 2020 at 22:35)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> are you able to spend some time on <a href="https://github.com/rust-lang/rust/issues/71154">#71154</a> this week? I think I am now fairly close to the optimal solution and considering its impact, I do want to get this done soon.</p>



<a name="198604216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/198604216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#198604216">(May 24 2020 at 23:01)</a>:</h4>
<p>I will try to take a look soon, but I think <span class="user-mention" data-user-id="119009">@eddyb</span> still wants to review as well before it is merged.</p>



<a name="199942039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/199942039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#199942039">(Jun 05 2020 at 22:44)</a>:</h4>
<p>Considering that MCPs are a thing now, this PR probably needs one <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> </p>
<p>I have an initial draft at <a href="https://gist.github.com/lcnr/f977d902d3f509d20d69d0110dba2f3f">https://gist.github.com/lcnr/f977d902d3f509d20d69d0110dba2f3f</a><br>
I am not sure on what I relevant here and what may need a more detailed explanation, so please ask for clarification or improvements where needed.</p>



<a name="199942315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/199942315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#199942315">(Jun 05 2020 at 22:48)</a>:</h4>
<p>I also talked a bit with <span class="user-mention silent" data-user-id="119009">eddyb</span> about the current implementation and may still end up changing how exactly parameters are passed into queries, which hopefully isn't too relevant for this MCP.</p>



<a name="200088977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200088977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200088977">(Jun 08 2020 at 12:18)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/compiler-team/issues/304">https://github.com/rust-lang/compiler-team/issues/304</a></p>



<a name="200089225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200089225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200089225">(Jun 08 2020 at 12:21)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="121053">@varkor</span> this PR still causes an ~1.5 % perf regression in some <a href="https://perf.rust-lang.org/compare.html?start=e4124750c33631042d5f078b78ce16286b8027c0&amp;end=384f9134ec3c49bfb8b7d20d1eaa9552358fc42b">benchmarks</a></p>



<a name="200089365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200089365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200089365">(Jun 08 2020 at 12:23)</a>:</h4>
<p>This is most probably caused by calling <code>tcx.with_opt_param(def_id)</code> before calling an already executed query, meaning that we now have 2 hashtable lookups instead of one.</p>



<a name="200089622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200089622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200089622">(Jun 08 2020 at 12:25)</a>:</h4>
<p>A solutation suggested by <span class="user-mention silent" data-user-id="119009">eddyb</span> and a previous approach was to instead allow queries to be called without the relevant param def id.<br>
And only call <code>tcx.const_param_of</code> inside of the query:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">unsafety_check_result</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">tcx</span>: <span class="nc">TyCtxt</span><span class="o">&lt;</span><span class="nb">&#39;_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">def</span>: <span class="nc">ty</span>::<span class="n">WithOptParam</span><span class="o">&lt;</span><span class="n">LocalDefId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">UnsafetyCheckResult</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">def</span><span class="p">.</span><span class="n">param_did</span><span class="p">.</span><span class="n">is_none</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">param_did</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">const_param_of</span><span class="p">(</span><span class="n">def</span><span class="p">.</span><span class="n">did</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">return</span><span class="w"> </span><span class="n">tcx</span><span class="p">.</span><span class="n">unsafety_check_result</span><span class="p">(</span><span class="n">ty</span>::<span class="n">WithOptParam</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">did</span>: <span class="nc">def</span><span class="p">.</span><span class="n">did</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">param_did</span>: <span class="nc">Some</span><span class="p">(</span><span class="n">param_did</span><span class="p">),</span><span class="w"></span>
<span class="w">            </span><span class="p">});</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="200090060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200090060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200090060">(Jun 08 2020 at 12:29)</a>:</h4>
<p>Just found a solution to my problem <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> Trying to explain exactly what's wrong works magic</p>



<a name="200090250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200090250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200090250">(Jun 08 2020 at 12:31)</a>:</h4>
<p>The problem was that we have to be able to reconstruct <code>WithOptParam</code> from a <code>DepNode</code></p>



<a name="200090331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200090331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200090331">(Jun 08 2020 at 12:32)</a>:</h4>
<p>I previously did this by using <code>dep_node.extract_def_id(tcx).map(|def_id| tcx.with_opt_param(def_id))</code></p>



<a name="200090469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200090469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200090469">(Jun 08 2020 at 12:33)</a>:</h4>
<p>This is wrong for <code>WithOptParam</code>s where <code>param_did != tcx.with_opt_param(def_id)</code>, resulting in ICE.</p>



<a name="200090616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200090616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200090616">(Jun 08 2020 at 12:34)</a>:</h4>
<p>Can be solved by splitting relevant queries into <code>query_name(def_id)</code> and <code>query_name_for_const_arg(with_opt_param)</code> and keeping the previous invariant of <code>WithOptParam</code>.</p>



<a name="200096482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200096482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200096482">(Jun 08 2020 at 13:24)</a>:</h4>
<p>Is there a quick way to profile how often a given query is called, even if it is already cached?</p>



<a name="200112738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200112738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200112738">(Jun 08 2020 at 15:19)</a>:</h4>
<p>Changed <code>resolve_instance</code> for now, which seems like it is the most frequently used query... Can someone start a perf run for <a href="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a>? (done)</p>



<a name="200511715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200511715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200511715">(Jun 11 2020 at 07:13)</a>:</h4>
<p>Well, I don't really know how what else I can try to fix perf here <span aria-label="disappointed" class="emoji emoji-1f61e" role="img" title="disappointed">:disappointed:</span> (without causing unsoundness)</p>
<p>The relevant perf results are <a href="https://perf.rust-lang.org/compare.html?start=e4124750c33631042d5f078b78ce16286b8027c0&amp;end=384f9134ec3c49bfb8b7d20d1eaa9552358fc42b">https://perf.rust-lang.org/compare.html?start=e4124750c33631042d5f078b78ce16286b8027c0&amp;end=384f9134ec3c49bfb8b7d20d1eaa9552358fc42b</a></p>



<a name="200512271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200512271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200512271">(Jun 11 2020 at 07:20)</a>:</h4>
<p>IMO this change is required to stabilize const generics and I am kind of unsure on how else we might implement this, so I think if noone else has an idea we should merge this even if it worsens perf by ~1.5% in some benchmarks</p>



<a name="200512596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200512596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200512596">(Jun 11 2020 at 07:26)</a>:</h4>
<p>I am very much biased towards getting const generics forward and don't care as much about perf, so there are probably other people who do want to see this merged, considering that const generics are still fairly far from stable.</p>



<a name="200512640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200512640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200512640">(Jun 11 2020 at 07:27)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> <span class="user-mention" data-user-id="119009">@eddyb</span> What's your stance here?</p>



<a name="200513066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200513066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200513066">(Jun 11 2020 at 07:33)</a>:</h4>
<p>An easy fix would be to close <a href="https://github.com/rust-lang/rust/issues/72962">#72962</a>, merge its commits on top of <a href="https://github.com/rust-lang/rust/issues/71154">#71154</a> and pretend like that PR is now perf neutral <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="200520378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200520378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200520378">(Jun 11 2020 at 09:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/const.20args.20in.20type.20dependent.20paths/near/200512596">said</a>:</p>
<blockquote>
<p>I am very much biased towards getting const generics forward and don't care as much about perf, so there are probably other people who do want to see this merged, considering that const generics are still fairly far from stable.</p>
</blockquote>
<p>other people who do <strong>not</strong> want to see this merged</p>



<a name="200878468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200878468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200878468">(Jun 15 2020 at 11:48)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>: sorry, I've been much busier than I expected these last couple of weeks, so I haven't managed to get to this PR, or really think about anything.</p>



<a name="200880835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200880835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200880835">(Jun 15 2020 at 12:16)</a>:</h4>
<p>I'm personally in favour of accepting a regression like that, considering that it is necessary to move CG forward. But I may be slightly biased :)</p>



<a name="200880887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200880887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200880887">(Jun 15 2020 at 12:16)</a>:</h4>
<p>I've had a read through the changes, and I don't see anything I think should be changed with the approach: my only real comments are about adding a few extra comments.</p>



<a name="200880944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200880944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200880944">(Jun 15 2020 at 12:17)</a>:</h4>
<p>But <span class="user-mention" data-user-id="119009">@eddyb</span> wanted to review this before any decision was made, so it's in their hands now.</p>



<a name="200888544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200888544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200888544">(Jun 15 2020 at 13:27)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> can I gently nudge you towards <a href="https://github.com/rust-lang/compiler-team/issues/304">https://github.com/rust-lang/compiler-team/issues/304</a> <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span> </p>
<p>One weird quirk I am not completely sure about is <a href="https://github.com/rust-lang/rust/pull/71154/commits/03f17ccf7f9a77deac74a3abc17984e2710de8ea">https://github.com/rust-lang/rust/pull/71154/commits/03f17ccf7f9a77deac74a3abc17984e2710de8ea</a> . This commit always uses <code>None</code> as <code>param_did</code> if the <code>def_id</code> is not local. Which should be fine as comparisons and hashing all  don't care about that field and we don't have to worry about cycles in these cases, but I want to explain this more clearly in a comment on <code>WithOptParam</code> itself, as it might be quite surprising</p>



<a name="200888639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200888639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200888639">(Jun 15 2020 at 13:28)</a>:</h4>
<p>Have an exam tomorrow so I will try to do it later this week</p>



<a name="200904820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200904820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200904820">(Jun 15 2020 at 15:27)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>: oh, what effect does this have on calling methods defined in other crates?</p>



<a name="200904881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200904881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200904881">(Jun 15 2020 at 15:27)</a>:</h4>
<p>We should add a test for cross-crate calling, even if we don't expect it to be problematic, as we've overlooked issues there before.</p>



<a name="200905742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200905742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200905742">(Jun 15 2020 at 15:33)</a>:</h4>
<p>The benefit of this is that we don't have to do two seperate query lookups when calling methods from extern crates.<br>
For the query cache <code>WithOptParam { did, param_did: Some(param) }</code> looks the same as <code>WithOptParam { did, param_did: None }</code>, so we still only cache it once. If something is reused computed both as local and extern, we may call <code>type_of(arg) -&gt; type_of(const_param_of(arg))</code> instead of <code>type_of(const_param)</code>.</p>



<a name="200905905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200905905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200905905">(Jun 15 2020 at 15:34)</a>:</h4>
<p>for the local crate, each call of <code>typeck_tables_of(def_id)</code> first requires a call to <code>const_param_of(def_id)</code></p>



<a name="200906305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200906305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200906305">(Jun 15 2020 at 15:35)</a>:</h4>
<p>I am not completely sold on this yete though, as the perf impact is fairly small afaict and its not very easy to reason about imo</p>



<a name="200906744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200906744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200906744">(Jun 15 2020 at 15:38)</a>:</h4>
<p>Is there a perf run recording the difference?</p>



<a name="200906833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200906833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200906833">(Jun 15 2020 at 15:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/const.20args.20in.20type.20dependent.20paths/near/200888544">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="121053">varkor</span> can I gently nudge you towards <a href="https://github.com/rust-lang/compiler-team/issues/304">https://github.com/rust-lang/compiler-team/issues/304</a> <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>
</blockquote>
<p>Ah, sorry, I've been completely behind. I've just seconded it.</p>



<a name="200917919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/200917919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#200917919">(Jun 15 2020 at 17:07)</a>:</h4>
<p>With <code>param_did: None</code>: <a href="https://perf.rust-lang.org/compare.html?start=bb8674837a9cc5225020e07fc3f164762bb4c11c&amp;end=0a204d6a1aef863bca037ca6e88ba49ce3e734ed">https://perf.rust-lang.org/compare.html?start=bb8674837a9cc5225020e07fc3f164762bb4c11c&amp;end=0a204d6a1aef863bca037ca6e88ba49ce3e734ed</a></p>
<p>With <code>param_did: tcx.const_param_of(def_id)</code>: <a href="https://perf.rust-lang.org/compare.html?start=e4124750c33631042d5f078b78ce16286b8027c0&amp;end=384f9134ec3c49bfb8b7d20d1eaa9552358fc42b">https://perf.rust-lang.org/compare.html?start=e4124750c33631042d5f078b78ce16286b8027c0&amp;end=384f9134ec3c49bfb8b7d20d1eaa9552358fc42b</a></p>



<a name="201059785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/201059785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#201059785">(Jun 16 2020 at 19:01)</a>:</h4>
<p>I tried to formulate why this is sound,  but wasn't able to even remove my own doubts <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>
<p>Will revert that change, meh</p>



<a name="201068243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/201068243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#201068243">(Jun 16 2020 at 20:15)</a>:</h4>
<p>Can someone perf <a href="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a>? Let's see where we are now</p>



<a name="201069504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/201069504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#201069504">(Jun 16 2020 at 20:26)</a>:</h4>
<p>(it seems the run has been queued already -- however, for faster iteration times, you can also run the benchmarks locally <a href="https://github.com/rust-lang/rustc-perf/tree/master/collector#how-to-benchmark-a-change-on-your-own-machine">https://github.com/rust-lang/rustc-perf/tree/master/collector#how-to-benchmark-a-change-on-your-own-machine</a>)</p>



<a name="201111085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/201111085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#201111085">(Jun 17 2020 at 08:01)</a>:</h4>
<p>prrrrrrrrrrrf <a href="https://perf.rust-lang.org/compare.html?start=a647c0cd68bdd0f15081019f0b21bc31ae23f072&amp;end=2e0ee43e993a0a97edc6a0af1116bfbccdf1dd36">https://perf.rust-lang.org/compare.html?start=a647c0cd68bdd0f15081019f0b21bc31ae23f072&amp;end=2e0ee43e993a0a97edc6a0af1116bfbccdf1dd36</a></p>
<p>I guess this is what we end up with</p>



<a name="203101181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/203101181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#203101181">(Jul 07 2020 at 13:25)</a>:</h4>
<p>hmm, in <a href="https://github.com/rust-lang/rust/pull/74113">https://github.com/rust-lang/rust/pull/74113</a> it seems like <code>@bors try</code> finished but nothing happened afterwards <span aria-label="oh no" class="emoji emoji-1f615" role="img" title="oh no">:oh_no:</span></p>
<p>Does someone know what happend there?</p>



<a name="203102173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/const%20args%20in%20type%20dependent%20paths/near/203102173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/const.20args.20in.20type.20dependent.20paths.html#203102173">(Jul 07 2020 at 13:32)</a>:</h4>
<p>If you push after <code>@bors try</code> then bors won't post a completed message. You can use <code>@rustc-perf build &lt;commit-hash&gt;</code> to run perf.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>